/********************************************
*
*
*
*  test_CallStack.c
*
*
********************************************/


#ifdef __cplusplus
 #if __cplusplus
  extern "C"{
 #endif
#endif /* __cplusplus */


#include "test_suite.h"
#include "d_callstack.h"

VOID TEST_Fun_0123456789_0123456789_0123456789_12341234()
{

}

UINT32 TEST_DMS_GetFuncName_00()
{
    CHAR acFuncName[DMS_CALLSTACK_MAX_FUNC_NAME+100];

    CU_EQUAL(DMS_OK, DMS_GetFuncName((VOID *)TEST_Fun_0123456789_0123456789_0123456789_12341234,acFuncName));

    printf("%d == %s\n",(UINT32)strlen(acFuncName),acFuncName);

    return DMS_OK;
}

UINT32 TEST_DMS_GetFuncName_01()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetFuncName_02()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetFuncName_03()
{

    return DMS_OK;
}

VOID TEST_Fun_0123456789_0123489_01234AbBB56789_12341234_1212(CALLSTACK * pstCallStackInfo)
{
static UINT32 ulRet = 10;
    if(ulRet)
    {
        ulRet -- ;
        TEST_Fun_0123456789_0123489_01234AbBB56789_12341234_1212(pstCallStackInfo);
    }
    else
    {
        ulRet = DMS_GetCallStackSymbols(pstCallStackInfo ,1);
        CU_EQUAL(DMS_OK, ulRet);
    }
}


UINT32 TEST_DMS_GetCallStackSymbols_00()
{
    UINT32 uli;
    CALLSTACK stCallStackInfo;

    TEST_Fun_0123456789_0123489_01234AbBB56789_12341234_1212(&stCallStackInfo);

    printf("\n<--- CallStackInfo\n");
    for( uli = 0 ; uli < stCallStackInfo.ulNum; uli++ )
    {
        printf("<--- %s\n",(CHAR *)stCallStackInfo.acFuncName[uli]);
    }

    return DMS_OK;
}



UINT32 TEST_DMS_GetCallStackSymbols_01()
{
    VOID * p;
    p = DMS_GetFuncAddr("printf");
    CU_EQUAL((VOID *)printf, p);

    p = DMS_GetFuncAddr("TEST_DMS_GetCallStackSymbols_01");
    CU_EQUAL((VOID *)TEST_DMS_GetCallStackSymbols_01, p);

    return DMS_OK;
}

UINT32 TEST_DMS_GetCallStackSymbols_02()
{

    return DMS_OK;
}

UINT32 TEST_DMS_GetCallStackSymbols_03()
{

    return DMS_OK;
}

VOID TEST_DMS_GetFuncName()
{
    CU_EQUAL(TEST_DMS_GetFuncName_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetFuncName_01(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetFuncName_02(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetFuncName_03(),DMS_OK);
}


VOID TEST_DMS_GetCallStackSymbols()
{
    CU_EQUAL(TEST_DMS_GetCallStackSymbols_00(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetCallStackSymbols_01(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetCallStackSymbols_02(),DMS_OK);
    CU_EQUAL(TEST_DMS_GetCallStackSymbols_03(),DMS_OK);
}

VOID TEST_suite_CallStack(VOID)
{
    CU_pSuite suite;
    suite = CU_add_suite(__FUNCTION__, NULL, NULL);
    CU_ADD_TEST(suite, TEST_DMS_GetFuncName);
    CU_ADD_TEST(suite, TEST_DMS_GetCallStackSymbols);
}

#ifdef __cplusplus
 #if __cplusplus
  }
 #endif
#endif /* __cplusplus */
